package com.xidian.zhiancloud.controller.luling.PointPart;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.CraftNodeStatus;
import com.xidian.zhiancloud.service.luling.PointPart.CraftNodeStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.xidian.zhiancloud.dto.ResultDTO.successOf;

/**
 ** 工艺节点清单接口
 * @Author:luling
 * @Date:2021/1/5  18:03
 */
@RestController
@RequestMapping("/CraftNodeStatus")
public class CraftNodeStatusController {
    @Autowired
    private CraftNodeStatusService craftNodeStatusService;
    /**
     * 添加工艺节点信息
     * @param  craftNodeStatus  工艺节点对象
     * @return ResultDTO对象
     */
    @PostMapping("/insert")
    public ResultDTO<Boolean> insert(@RequestBody CraftNodeStatus craftNodeStatus) {
        craftNodeStatusService.insert(craftNodeStatus);
        return successOf(GeneralResponseEnums.SUCCESS);
    }
    /**
     * 删除工艺节点信息
     * @param  craftNodeStatus  删除工艺节点对象
     * @return ResultDTO对象
     */
    @PostMapping("/delete")
    public ResultDTO<Boolean> delete(@RequestBody CraftNodeStatus craftNodeStatus) {
        craftNodeStatusService.delete(craftNodeStatus);
        return successOf(GeneralResponseEnums.SUCCESS);
    }
    /**
     * 修改工艺节点信息
     * @param  craftNodeStatus  修改工艺节点对象
     * @return ResultDTO对象
     */
    @PostMapping("/update")
    public ResultDTO<Boolean> update(@RequestBody CraftNodeStatus craftNodeStatus) {
        craftNodeStatusService.update(craftNodeStatus);
        return successOf(GeneralResponseEnums.SUCCESS);
    }
    /**
     * 根据id删除工艺节点信息
     * @param  ids ids数组
     * @return  返回ResultDTO对象
     */
    @DeleteMapping("/deleteByIds")
    public ResultDTO<Boolean> deleteByIds(Long[] ids) {
        craftNodeStatusService.deleteByIds(ids);
        return successOf(GeneralResponseEnums.SUCCESS);
    }
    /**
     * 根据nodeType 查询工艺节点信息
     * @param  nodeType nodeType  工艺节点类型
     * @return ResultDTO对象
     */
    @GetMapping("/getById/{nodeType}")
    public ResultDTO<List<CraftNodeStatus>> getById(
            @PathVariable String nodeType) {
        return successOf(craftNodeStatusService.getById(nodeType), GeneralResponseEnums.SUCCESS);
    }
//    /**列表查询
//     * @param  nodeName 工艺节点名称
//     * @param  introduction  工艺节点描述
//     * @param   addBy  添加人
//     * @param  key 关键字
//     * @param current 分页偏移量
//     * @param size 每一页的数量
//     * @return 返回工艺节点列表
//
//    @GetMapping("/getList")
//    public ResultDTO<List<CraftNodeStatus>> selectcraftNodeStatusList (
//                             @RequestParam(value = "nodeName", required = false) String nodeName,
//                             @RequestParam(value = "introduction", required = false) String introduction,
//                             @RequestParam(value = "addBy", required = false) String addBy,
//                             @RequestParam(value = "key", required = false) String key,
//                             @RequestParam(value = "current", required = true) int current,
//                             @RequestParam(value = "size", required = true) int size) {
//        return ResultDTO.successOf(craftNodeStatusService.getList(nodeName, introduction, addBy,key,current, size), GeneralResponseEnums.SUCCESS);
//    }*/
//    @GetMapping("/getList")
//    public ResultDTO<IPage<CraftNodeStatusListVO>> getListByQueryObject(CraftNodeStatusListQO craftNodeStatusListQO) {
//        return ResultDTO.successOf(craftNodeStatusService.getListByQO(craftNodeStatusListQO), GeneralResponseEnums.SUCCESS);
//    }
}
